<template>
	<view>
		<hx-navbar ref="hxnb" :config="config" />
		<view class="typeList">
			<view v-if="index == 1">
				<view class="titleIndex">
					您的装修类型
				</view>
				<view class="flex justify-between" style="margin: 30rpx;flex-wrap:wrap">
					<view class="flex justify-between" v-for="(item,index) in typeList" :key="index">
						<view class="type" :class="typeTindex==index ? 'typeStyle' :''"
							@click="typeChild(index,item.id,item.name)">
							{{item.name}}
						</view>
					</view>
				</view>
			</view>
			<view v-if="index == 2">
				<view class="titleIndex">
					喜欢风格
				</view>
				<view class="flex justify-between" style="margin: 30rpx;flex-wrap:wrap">
					<view class="flex justify-between" v-for="(item,index) in styleList" :key="index">
						<view class="type" :class="styleTindex==index ? 'typeStyle' :''"
							@click="styleChild(index,item.id,item.name)">
							{{item.name}}

						</view>
					</view>
				</view>
			</view>
			<view v-if="index == 3">
				<view class="titleIndex">
					标签
				</view>
				<view class="flex justify-between" style="margin: 30rpx;flex-wrap:wrap">
					<view class="flex justify-between" v-for="(item,index) in styleList" :key="index">
						<view class="type" :class="styleTindex==index ? 'typeStyle' :''"
							@click="styleChild(index,item.id)">
							{{item.name}}
						</view>
					</view>
				</view>
			</view>
			<view class="seek" @click="determine">
				确定
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				index: '',
				config: {
					title: '',
					color: '#111111',
					backgroundColor: [1, '#FFFFFF'],
					border: true,
					// #ifdef H5
					backPage: '',
					// #endif
				},
				// 装修类型
				typeList: [],
				typeTindex: 0,
				// 喜欢风格
				styleList: [],
				styleTindex: 0,
				// 1v1
				categoryData: {
					categoryId: '',
					categoryName: '',
				},
				typeData: {
					typeId: '',
					typeName: '',
				}
			}
		},
		onLoad(e) {
			this.index = e.index
			console.log('哈哈哈哈', this.index)
			this.material()
			if (this.index == 1) {
				this.config.title = "装修类型"
			} else if (this.index == 2) {
				this.config.title = "喜欢风格"
			} else {
				this.config.title = "更多"
			}
		},
		methods: {
			// 装修类型、喜欢风格
			material() {
				this.$api.plteList().then((res) => {
					this.typeList = res.data.result.decorationTypeList;
					this.typeData.typeId = this.typeList[0].id;
					this.styleList = res.data.result.categoryList;
					this.categoryId.categoryId = this.styleList[0].id;
					console.log('风格', this.typeId)
				})
			},
			// 装修类型
			typeChild(e, id, name) {
				this.typeTindex = e
				this.typeData.typeId = id
				this.typeData.typeName = name
				// console.log('风格1', this.typeId)
				if (id == 1) id = ''
			},
			// 喜欢风格
			styleChild(e, id, name) {
				this.styleTindex = e
				this.categoryData.categoryId = id
				this.categoryData.categoryName = name
				// console.log('风格2', this.categoryId)
				if (id == 1) id = ''
			},
			// 确定
			determine() {
				if (this.index == 1) {
					uni.switchTab({
						url: '/pages/tabbar/clientEndTabbar/ClientHome'
					})
					uni.$emit('typeId', {
						typeData: this.typeData
					})
				} else if (this.index == 2) {
					uni.switchTab({
						url: '/pages/tabbar/clientEndTabbar/ClientHome'
					})
					uni.$emit('categoryId', {
						categoryData: this.categoryData
					})
				}
			}
		}
	}
</script>

<style scoped>
	.seek {
		width: 554rpx;
		height: 108rpx;
		background: #492D22;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		font-size: 36rpx;
		font-family: Noto Sans SC-Regular, Noto Sans SC;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 108rpx;
		text-align: center;
		margin: 45rpx auto;
	}

	.titleIndex {
		font-size: 36rpx;
		font-family: Noto Sans SC-Regular, Noto Sans SC;
		font-weight: 400;
		padding: 0 30rpx;
		color: #1E1E1E;
	}

	.typeList {
		background: #FFFFFF;
		padding: 30rpx;
	}

	.typeStyle {
		background: #492D22 !important;
		color: #fFFFFF !important;
	}

	.type {
		width: 208rpx;
		height: 112rpx;
		background: rgba(0, 136, 255, 0.03);
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		border: 2rpx solid rgba(73, 45, 34, 0.1);
		font-size: 32rpx;
		font-family: Noto Sans SC-Medium, Noto Sans SC;
		font-weight: 500;
		color: #1E1E1E;
		line-height: 58rpx;
		text-align: center;
		line-height: 112rpx;
		margin-bottom: 30rpx;
	}
</style>
